import sequence
import argparse

def create_dataset(k:int=0.001, mode:str="all", psub:int=1514, window_size:int=100):
        config = {
            "mode": mode,
            "k": k,
            "psub": psub,
            "window_size": window_size,
        }
        injector = sequence.Injector(config)
        output_dir = injector.create_API_dataset()
        print(output_dir)

def create_API_datasets(type:str, k:int=0.001, mode:str="all", psub:int=1514, window_size:int=100):
    """Create several API datasets.

    Args:
        type: "window", "mode", "k" or "psub"

    """
    window_list = [50, 100, 150, 200]
    mode_list = ["src2dst", "dst2src", "all"]
    k_list = [0.001, 0.002, 0.003, 0.004, 0.005]
    psub_list = [14 + i for i in range(100, 1600, 200)]  # [114, 314, 514, 714, 914, 1114, 1314, 1514]
    

    v_list = []
    if type == "k": v_list = k_list
    elif type == "mode": v_list = mode_list
    elif type == "psub": v_list = psub_list
    elif type == "window": v_list = window_list

    for v in v_list:
        if type == "k": k = v
        elif type == "mode": mode = v
        elif type == "psub": psub = v
        elif type == "window": window_size = v
        create_dataset(k, mode, psub, window_size)

def main():
    parser = argparse.ArgumentParser(description="Evaluate.")

    parser.add_argument(
        "--type","-t",
        type=str,
        help="support type 'window', 'k', 'mode', 'psub'"
    )

    parser.add_argument(
        "--window_size","-w",
        type=int,
        default=100,
    )

    parser.add_argument(
        "-k",
        type=float,
        default=0.001,
    )

    parser.add_argument(
        "--mode", "-m",
        type=str,
        default="all",
    )

    parser.add_argument(
        "-psub",
        type=int,
        default=1514,
    ) 
    args = parser.parse_args()

    if args.type != None:
        create_API_datasets(
            type=args.type,
        )
    else:
        create_dataset(k=args.k, mode=args.mode, psub=args.psub, window_size=args.window_size)

if __name__ == "__main__":
    main()